let sum = ref 0 in
for i=0 to 999 do
   if ( ( i mod 3 = 0 ) || ( i mod 5 = 0 ) ) then
      begin
      print_endline (string_of_int i);
      sum := !sum + i;
      end
done;
print_endline (string_of_int !sum);;
